//
//  CLNumberButton.h
//  CLPPbutton
//
//  Created by 小草毋正 on 2018/3/16.
//  Copyright © 2018年 zwc. All rights reserved.
//

#import <UIKit/UIKit.h>

@class CLNumberButton;

@protocol CLNumberButtonDelegate <NSObject>

@optional

/**
 * @abstract 加减代理回调
 *
 * @param numberButton   按钮
 * @param number         当前数值
 * @param increaseStatus 是否为加
 */
- (void)cl_numberButton:(CLNumberButton *)numberButton
                 number:(NSInteger)number
         increaseStatus:(BOOL)increaseStatus;

@end



IB_DESIGNABLE

@interface CLNumberButton : UIView

+ (instancetype)numberButtonWithFrame:(CGRect)frame;

@property (nonatomic, copy) void(^resultBlock)(NSInteger number, BOOL increaseStatus);
@property (nonatomic, weak) id<CLNumberButtonDelegate> delegate;


/** 最大值 */
@property (nonatomic, assign) IBInspectable NSInteger maxValue;
/** 最小值 */
@property (nonatomic, assign) IBInspectable NSInteger minValue;
@property (nonatomic, assign) IBInspectable NSInteger currentValue;

/** 长按加减的时间间隔,默认0.1s,设置为 CGFLOAT_MAX 则关闭长按加减功能*/
@property (nonatomic, assign) IBInspectable CGFloat longPressSpaceTime;

/** 加按钮标题 */
@property (nonatomic, copy) IBInspectable NSString *increaseTitle;
/** 减按钮标题 */
@property (nonatomic, copy) IBInspectable NSString *decreaseTitle;

/** 加按钮背景图片 */
@property (nonatomic, strong) IBInspectable UIImage *increaseImage;
/** 减按钮背景图片 */
@property (nonatomic, strong) IBInspectable UIImage *decreaseImage;

/** 输入框字体大小 */
@property (nonatomic, assign) IBInspectable CGFloat inputFieldFont;
/** 按钮字体大小 */
@property (nonatomic, assign) IBInspectable CGFloat buttonTitleFont;
/** 边框颜色，不设置则没有边框 */
@property (nonatomic, strong) IBInspectable UIColor *borderColor;

/** 数量为小于最小值的时候隐藏 */
@property (nonatomic, assign) IBInspectable BOOL descreaseHide;
/** 是否可以编辑输入框 */
@property (nonatomic, assign, getter = isEditing) IBInspectable BOOL editing;
/** 是否开启抖动动画 */
@property (nonatomic, assign) BOOL shakeAnimation;

@end


#pragma mark- ==== NSString 分类 ====
@interface NSString (CLNumberButton)

/**
 * 字符串 nil,@"", @"  ",@"\n"  Returns NO;
 *
 * 其他 Returns YES.
 */
- (BOOL)cl_isNotBlank;

@end



